﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Sharp.DataTransferObject;
using Sharp.Portal.Interface;
using Sharp.WebBooter.Areas.Platform.Models;

namespace Sharp.WebBooter.Areas.Platform
{

    /// <summary>
    /// 安装
    /// </summary>
    public class Install : INavigation
    {
        /// <summary>
        /// 导航
        /// </summary>
        /// <returns></returns>
        /// <remarks>导航即权限数据</remarks>
        public IList<PermissionDTO> Navigation()
        {
            var permissionData = new List<PermissionDTO>();
            var platformData =
                   new List<PermissionDTO>()
                   {

new PermissionDTO("002", "平台维护", 2, "", "fa fa-home"){IsShortcut=true},
//new PermissionDTO("002001", "日志监控", 0, "/Platform/LogMonitor/", "fa fa-eye"),
new PermissionDTO("002002", "系统设置", 1, "/Platform/Setting/", "fa fa-cog"),
new PermissionDTO("002003", "主数据", 2, "/Platform/MasterData/", "fa fa-circle-o"),
new PermissionDTO("002004", "用户日志", 3, "/Platform/UserLog/", "fa fa-pencil-square-o"){ForFieldPermission=new UserLogIndexViewModel().ColumnItems},
new PermissionDTO("002005", "系统接入", 4, "/Platform/SubSystem/", "fa fa-free-code-camp"){ForFieldPermission=new SubSystemIndexModel().ColumnItems},
new PermissionDTO("002006", "快捷登录", 5, "/Platform/OAuth/", "fa fa-qq"),
new PermissionDTO("002007", "可用权限", 6, "/Platform/AvailablePermission/", "fa fa-superpowers"),

new PermissionDTO("001", "用户", 1, "/User/", "fa fa-user"){IsShortcut=true},
new PermissionDTO("001001", "用户管理", 0, "/Platform/User/", "fa fa-user"){ForFieldPermission=new UserIndexViewModel().ColumnItems},
new PermissionDTO("001003", "角色管理", 1, "/Platform/Role/", "fa fa-user-circle"){ForFieldPermission=new RoleIndexViewModel().ColumnItems},


new PermissionDTO("003", "组织结构", 0, "", "fa fa-cog"){IsShortcut=true},
new PermissionDTO("003001", "员工管理", 0, "/Platform/Employee/", "fa fa-exchange"){ForFieldPermission=new EmployeeIndexModel().ColumnItems},
new PermissionDTO("003002", "组织结构", 1, "/Platform/Org/", "fa fa-files-o"){ForFieldPermission=new OrgIndexViewModel().ColumnItems},
new PermissionDTO("003003", "岗位管理", 2, "/Platform/Job/", "fa fa-hand-spock-o"){ForFieldPermission=new JobIndexModel().ColumnItems},
new PermissionDTO("003004", "工作组", 2, "/Platform/Group/", "fa fa-check-circle-o"){ForFieldPermission=new GroupIndexModel().ColumnItems},
new PermissionDTO("003005", "组织层级", 1, "/Platform/OrgLevel/", "fa fa-files-o"){ForFieldPermission=new OrgLevelIndexViewModel().ColumnItems},

new PermissionDTO("004", "工作", 4, "", "fa fa-id-badge"){IsShortcut=true},
new PermissionDTO("004001", "消息管理", 1, "/Platform/Message/", "fa fa-comments"),
new PermissionDTO("004002", "通知管理", 2, "/Platform/Notice/", "fa fa-commenting"),


                   };
            platformData.ForEach(x =>
            {
                x.SystemCode = "Platform";
                x.Id = Guid.Parse($"{x.Code}_{x.SystemCode}_{x.Category}".Md5());
                var parent = platformData.FirstOrDefault(c =>
                    c.SystemCode == x.SystemCode &&
                    x.Code.StartsWith(c.Code) &&
                    c.Code.Length == x.Code.Length - 3);
                if (parent != null)
                {
                    x.ParentId = parent.Id;
                }
                else
                {
                    x.ParentId = null;
                }
            });
            permissionData.AddRange(platformData);

            return permissionData;
        }

        public bool IsDevOnly { get; set; }
    }
}